<header class="navbar navbar-static-top tms-nav">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand sys-color" href="${request.contextPath}/index.action">教学过程控制系统</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="tms-nav-collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="${request.contextPath}/register-step1.action">注册账号</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div>
  <script>
  var t = (new Date()).getTime();
  $.getJSON('${request.contextPath}/login-session.action', {'t':t}, function(json, textStatus) {
    if (json['nickname'] != null) {
      var html = '';
      html += '<li class="dropdown">';
      html += '  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + json['nickname'] + ' <span class="caret"></span></a>';
      html += '  <ul class="dropdown-menu">';
      html += '    <li><a href="${request.contextPath}/user-' + json['id'] + '.action">个人中心</a></li>';
      html += '    <li><a href="${request.contextPath}/team-list.action">我的团队</a></li>';
      html += '    <li><a href="#">修改资料</a></li>';
      html += '    <li role="separator" class="divider"></li>';
      html += '    <li><a href="###" class="j_logout">退出系统</a></li>';
      html += '  </ul>';
      html += '</li>';

      $('#tms-nav-collapse > ul').append(html);
    } else {
      $('#tms-nav-collapse > ul').append('<li><a href="${request.contextPath}/login-index.action">登录系统</a></li>');
    }
    console.log(json);
  });
  $(document).on('click', '.j_logout', function() {
    $.getJSON('${request.contextPath}/login-invalide.action', {'t':t}, function(json, textStatus) {
      if (json['status'] === 1) {
        window.location.href = '${request.contextPath}/index.action';
      }
    });

  });
  </script>
</header>
